package com.hightrast.service.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.hightrast.service.api.domain.qo.rastRole.QueryRastRoleListQo;
import com.hightrast.service.api.entity.RastRole;
import com.hightrast.service.mapper.RastRoleMapper;
import com.hightrast.service.service.IRastRoleService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 角色表 服务实现类
 * </p>
 *
 * @author hx
 * @since 2025-01-11
 */
@Service
public class RastRoleServiceImpl extends ServiceImpl<RastRoleMapper, RastRole> implements IRastRoleService {

    /**
     * 获取角色列表
     * @param qo
     * @return
     */
    @Override
    public List<RastRole> queryRoles(QueryRastRoleListQo qo) {
        return this.list(new LambdaQueryWrapper<RastRole>()
                .eq(qo.getRoleId() != null ,RastRole::getId,qo.getRoleId())
                .like(StringUtils.isNotEmpty(qo.getRoleName()), RastRole::getRoleName,"%" + qo.getRoleName() + "%"));
    }
}
